Get AppleScript command, application command
The Get command can function as an AppleScript command or an application command. The AppleScript command returns the value of an expression.
The application command returns the value of an object. In both cases, the command assigns the value returned to the predefined variableresult
.APPLESCRIPT COMMAND SYNTAX
[ get ] expression [ as className ]APPLICATION COMMAND SYNTAX
[ get ] referenceToObject [ as className ]PARAMETERS
- expression
- An expression whose value is to be returned in the
result
variable.
Class: Any AppleScript expression- className
- A class identifier that specifies the desired value class for
the returned data.
Class: Class
Default value: The default value class for the object or objects- referenceToObject
A reference to an object whose value is to be returned in theresult
variable.
Class: ReferenceRESULT
The result is the value of the specified reference or expression.If the referenceToObject parameter specifies a single object only (such as
word 1
orthe last word
), the result is a single value. If the specified object doesn't exist, for example, if the reference isword 12
and there are fewer than 12 words in the specified container, no result is returned.If the referenceToObject parameter refers to more than one object (such as
the words whose first letter is "B"
), the result is a list of values. The first item in the list is the value of the first object specified, the second item is the value of the second object specified, and so on. If the specified objects don't exist, for example, if the reference isthe words whose first letter is "B"
and there are no words that begin with "B", the result is an empty list.Class: The class specified by the className parameter or a list of values of that class. If the application cannot return data in the value class specified by the className parameter, it returns a value or values of the default value class.
EXAMPLE
tell application "Scriptable Text Editor" get paragraph 3 --gets the value copy result to item 2 of x --puts the result end tellNOTES
The wordget
in the Get command is optional because AppleScript automatically gets the value of expressions and references when they
appear in scripts.For example, the following statements are equivalent:
item 1 of {"Hi,", "how", "are", "you?"} get item 1 of {"Hi,", "how", "are", "you?"}The following statements are also equivalent:
tell application "Scriptable Text Editor" word 1 of document "Introduction"end tell tell application "Scriptable Text Editor" get word 1 of document "Introduction"end tellERROR
Error
numberError message -1728 Can't get <reference>.